package com.example.zsf.presenter;


import com.example.zsf.base.Presenter;
import com.example.zsf.base.ZSFGlobal;
import com.example.zsf.network.Api;
import com.example.zsf.network.RetrofitManager;

import java.util.HashMap;

import retrofit2.Call;

public class MobilePresenter extends Presenter {
    public static <T> Call<T> getList(Integer pcOrMobile, PresenterListener<T> presenterListener) {
        Api api = RetrofitManager.getInstance()
                .setBaseUrl(ZSFGlobal.baseUrl)
                .build(Api.class);
        HashMap params = new HashMap();
        params.put("type", pcOrMobile);
        Call call = api.getList(params);
        call.enqueue(new SampleCallback(presenterListener));
        return call;
    }

    public static <T> Call<T> getAdInfo(String id, PresenterListener<T> presenterListener) {
        Api api = RetrofitManager.getInstance()
                .setBaseUrl(ZSFGlobal.baseUrl)
                .build(Api.class);
        HashMap params = new HashMap();
        params.put("ads_id", id);
        Call call = api.getAdInfo(params);
        call.enqueue(new SampleCallback(presenterListener));
        return call;
    }


    public static <T> Call<T> favorite(String id, String type, PresenterListener<T> presenterListener) {
        Api api = RetrofitManager.getInstance()
                .setBaseUrl(ZSFGlobal.baseUrl)
                .build(Api.class);
        HashMap params = new HashMap();
        params.put("ads_id", id);
        params.put("type", type);
        Call call = api.favorite(params);
        call.enqueue(new SampleCallback(presenterListener));
        return call;
    }

    public static <T> Call<T> getPayList(String id, PresenterListener<T> presenterListener) {
        Api api = RetrofitManager.getInstance()
                .setBaseUrl(ZSFGlobal.baseUrl)
                .build(Api.class);
        HashMap params = new HashMap();
        params.put("ads_id", id);
        Call call = api.getPayList(params);
        call.enqueue(new SampleCallback(presenterListener));
        return call;
    }

    public static <T> Call<T> enterInfo(String id, String game_name, String game_name_ver, String open_name, PresenterListener<T> presenterListener) {
        Api api = RetrofitManager.getInstance()
                .setBaseUrl(ZSFGlobal.baseUrl)
                .build(Api.class);
        HashMap params = new HashMap();
        params.put("ads_id", id);
        params.put("game_name", game_name);
        params.put("game_name_ver", game_name_ver);
        params.put("open_name", open_name);
        Call call = api.enterInfo(params);
        call.enqueue(new SampleCallback(presenterListener));
        return call;
    }

    public static <T> Call<T> grab(String id, String validate, PresenterListener<T> presenterListener) {
        Api api = RetrofitManager.getInstance()
                .setBaseUrl(ZSFGlobal.baseUrl)
                .build(Api.class);
        HashMap params = new HashMap();
        params.put("ads_id", id);
        params.put("validate", validate);
        Call call = api.grab(params);
        call.enqueue(new SampleCallback(presenterListener));
        return call;
    }

}
